<template>
	<view>
		<image mode="widthFix" :src="path" />
		<ksp-cropper mode="fixed" :width="600" :height="600" :maxWidth="1024" :maxHeight="1024" :url="iconUrl"
			@cancel="oncancel" @ok="onok"></ksp-cropper>
	</view>
</template>

<script>
	import icon from '../../uni_modules/uview-ui/libs/config/props/icon';
	export default {
		data() {
			return {
				iconUrl: "",
				path: "",
				options:{}
			}
		},
		onLoad(options) {
			this.options = options
			console.log('获取传递过来的裁剪图片链接', options)
			this.iconUrl = decodeURIComponent(options.path)
		},
		methods: {
			onok(ev) {
				console.log('点击裁剪确定了', ev)
				this.iconUrl = "";
				this.path = ev.path;

				let pages = getCurrentPages(); //获取所有页面栈实例列表
				let nowPage = pages[pages.length - 1]; //当前页页面实例
				let prevPage = pages[pages.length - 2]; //上一页页面实例
				console.log('获取确定后的裁剪路径', this.path, prevPage)
				prevPage.$vm.getCompressImage(this.path, this.options.size); //调用上个页面的方法
				uni.navigateBack()


			},
			oncancel() {
				// url设置为空，隐藏控件
				this.iconUrl = "";
				uni.navigateBack()
			},
			save(url) {
				let userInfo = uni.getStorageSync('userInfo')
				userInfo.Icon = url
				this.$http('Base_Manage/Base_VIPUserInfo/SaveData', userInfo).then(res => {
					if (res.Success) {
						uni.setStorageSync('userInfo', userInfo)
						uni.navigateBack()
					}
				})
			}
		}
	}
</script>